//
//  View+RoundCorner.swift
//  MagaCore
//
//  Created by qmdjx on 2023/5/20.
//

import Foundation
import SwiftUI

extension View {
  func cornerRadius(_ radius: CGFloat, corners: UIRectCorner) -> some View {
    clipShape( RoundedCorner(var_radius: radius, var_corners: corners) )
  }
}

struct RoundedCorner: Shape {
  var var_radius: CGFloat = .infinity
  var var_corners: UIRectCorner = .allCorners
  func path(in rect: CGRect) -> Path {
    let path = UIBezierPath(roundedRect: rect, byRoundingCorners: var_corners, cornerRadii: CGSize(width: var_radius, height: var_radius))
    return Path(path.cgPath)
  }
}
